#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
class Solution {
public:
    string compressString(string param) {
        string str;
        int i = 1, count = 1;
        str += param[0];
        while (i < param.size())
        {
            if (param[i] != param[i - 1])
            {
                if (count != 1) str += to_string(count);
                count = 1;
                str += param[i];
            }
            else
            {
                count++;
            }
            i++;
        }
        if (count != 1)
        {
            str += to_string(count);
        }
        return str;
    }
};

using namespace std;
typedef long long ll;
const ll N = 1000000;
pair<ll, ll> a[N];
int n, k;

bool cmp(const pair<ll, ll>& p1, const pair<ll, ll>& p2)
{
    if (p1.second > p2.second)return true;

    else if (p1.second == p2.second)
        return p1.first < p2.first;
    else
        return false;
}

int dp[1100] = { 0 };
int knapsack(int V, int n, vector<vector<int> >& vw) {

    for (int i = 0; i < n; i++) {
        for (int j = V; j >= vw[i][1]; j--) {
            dp[j] = max(dp[j], dp[j - vw[i][0]] + vw[i][1]);
        }
    }

    return dp[V];
}

int main()
{
    ll _acid = 0, _sweet = 0;
    cin >> n >> k;
    for (ll i = 0; i < n; i++) { cin >> a[i].first; }
    for (ll i = 0; i < n; i++) { cin >> a[i].second; }
    sort(a, a + n, cmp);

    for (ll i = 0; i < k; i++)
    {
        _acid += a[i].first;
        _sweet += a[i].second;
    }
    cout << _acid << " " << _sweet << endl;

    return 0;
}

int aknapsack(int V, int n, vector<vector<int> >& vw) {
    vector<vector<int>> dp(n + 1, vector<int>(V + 1, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= V; j++) {
            if (vw[i - 1][0] > j) {
                dp[i][j] = dp[i - 1][j];
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - vw[i - 1][0]] + vw[i - 1][1]);
            }
        }
    }

    return dp[n][V];
}


void Test1()
{

}